

// ServiceInfo.java

package com.ruoyi.hospital.entity.check;

import com.ruoyi.hospital.entity.ServiceChargeItem;
import com.ruoyi.hospital.entity.ServiceChargeVO;

import java.util.ArrayList;
import java.util.List;

/**
 * 服务明细
 */
@lombok.Data
public class CheckServiceInfo {
    /**
     * 服务费总额
     */
    private Long serviceCharge = 0L;
    /**
     * 患者的原订单
     */
    private List<CheckServiceInfoFromPat> fromPat;
    /**
     * 护士补充的服务
     */
    private List<CheckServiceInfoFromNur> fromNur;

    public void init(ServiceChargeVO serviceCharge){
        if(this.fromPat == null){
            this.fromPat = new ArrayList<CheckServiceInfoFromPat>();
        }
        if(this.fromNur == null){
            this.fromNur = new ArrayList<CheckServiceInfoFromNur>();
        }
        for (ServiceChargeItem item : serviceCharge.getServiceChargeItemList()){
            if (item.getNewFlag() == 0){
                CheckServiceInfoFromPat patNode = new CheckServiceInfoFromPat();
                patNode.setItemId(item.getItemId());
                patNode.setComboId(item.getComboId());
                patNode.setName(item.getItemName() + "_" + item.getComboName());
                patNode.setPrice(item.getPrice());
                patNode.setNum(item.getCount());
                patNode.setCost(item.getPrice() * item.getCount());
                this.setServiceCharge(this.getServiceCharge() + item.getPrice() * item.getCount());
                this.fromPat.add(patNode);
            }
            if (item.getNewFlag() == 1){
                CheckServiceInfoFromNur nurNode = new CheckServiceInfoFromNur();
                nurNode.setItemId(item.getItemId());
                nurNode.setComboId(item.getComboId());
                nurNode.setName(item.getItemName() + "_" + item.getComboName());
                nurNode.setPrice(item.getPrice());
                nurNode.setNum(item.getCount());
                nurNode.setCost(item.getPrice() * item.getCount());
                this.setServiceCharge(this.getServiceCharge() + item.getPrice() * item.getCount());
                this.fromNur.add(nurNode);
            }
        }

    }

}
